package sc
{
	import mx.controls.Alert;
	import mx.events.CloseEvent;
	
	import air.update.ApplicationUpdaterUI;
	import air.update.events.UpdateEvent;

	import flash.filesystem.File;
	import flash.events.ErrorEvent;
	import flash.events.Event;
	public class Update
	{
		private var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI;
		
		public function Update()
		{
			appUpdater.updateURL = "http://developer.xf.cz/flexy_site/update.xml";
				appUpdater.delay = 0.01;
				//by default all the dialogs are hidden
				appUpdater.isCheckForUpdateVisible = false;
				appUpdater.isDownloadUpdateVisible = true;
				appUpdater.isDownloadProgressVisible = true;
				appUpdater.isInstallUpdateVisible = true; 

				// end updater config
				
				// Or you can write all the config in an xml file
				// appUpdater.configurationFile = new File("app:/config/update.xml");
				
				//it is necessary to add an ErrorEvent listener because this type of events are catched by the debugger
				appUpdater.addEventListener(ErrorEvent.ERROR, updateError);
				trace('check');
				appUpdater.initialize();
				appUpdater.checkNow();		
	
		}
		
		public static function updateError(ev:ErrorEvent):void{
            	Alert.show(ev.toString());
		}

	}
}